import { createPinia } from "pinia";

import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; //使用持久化插件

const pinia = createPinia();

pinia.use(piniaPluginPersistedstate);
pinia.use(({ store }) => {
  // 保存初始状态的副本
  const initialState = JSON.parse(JSON.stringify(store.$state));
  // 定义 reset 方法
  store.$reset = () => {
    store.$patch(initialState);
  };
});
export { useUserStore } from "./modules/user";
export { useWebSocketStore } from "./modules/websocket";
export { useSearchStore } from "./modules/search";
export { pinia };
